package com.thinkerwolf.dtx.mq.bank1.config;

import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/**
 * 切面
 * Spring AOP就是将切面中的通知织入到切面中的连接点
 * 连接点就是 切入点和通知之间的连接
 *
 * @author wukai
 */
@Aspect
@Component
public class ServiceMethodAspect {
    /**
     * 切入点 pointcut
     */
    @Pointcut("execution(* * com.thinkerwolf.dtx.mq.bank1.service..*.*(..))")
    private void pointCut() {
    }

    /**
     * 前置通知 before
     */
    @Before("pointCut()")
    public void beforeAdvice() {
        System.err.println("Going to invoke service method.");
    }

    /**
     * 后置通知 before
     */
    @After("pointCut()")
    public void afterAdvice() {
        System.err.println("Service method invoke finish.");
    }

    /**
     * 方法返回后通知 before
     *
     * @param retVal
     */
    @AfterReturning(pointcut = "pointCut()", returning = "retVal")
    public void afterReturningAdvice(Object retVal) {
        System.err.println("Returning:" + retVal.toString());
    }
}
